package com.zhijie.common.util;


import java.io.Serializable;

/**
 * @ClassName: 封装返回类
 * @Description:
 * @author: tongzhijie
 * @date: 2019/10/17
 */
public class ResponseData<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    private int code;

    private String msg;

    private T data;

    private ResponseData() {
    }

    public int getCode() {
        return code;
    }

    private void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    private void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    private void setData(T data) {
        this.data = data;
    }

    private ResponseData(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }


    public static ResponseData SUCCESS() {
        return new ResponseData(HttpStatusEnum.SUCCESS_DEFAULT.getCode(), HttpStatusEnum.SUCCESS_DEFAULT.getMsg(), null);
    }


    public static ResponseData SUCCESSMSG(String msg) {
        return new ResponseData(HttpStatusEnum.SUCCESS_DEFAULT.getCode(), msg, null);
    }

    public static <T> ResponseData SUCCESS(T data) {
        return new ResponseData(HttpStatusEnum.SUCCESS_DEFAULT.getCode(), HttpStatusEnum.SUCCESS_DEFAULT.getMsg(), data);
    }

    public static <T> ResponseData SUCCESS(String msg, T data) {
        return new ResponseData(HttpStatusEnum.SUCCESS_DEFAULT.getCode(), msg, data);
    }

    public static ResponseData ERROR() {
        return new ResponseData(HttpStatusEnum.ERROR_DEFAULT.getCode(), HttpStatusEnum.ERROR_DEFAULT.getMsg(), null);
    }

    public static ResponseData ERRORMSG(String msg) {
        return new ResponseData(HttpStatusEnum.ERROR_DEFAULT.getCode(), msg, null);
    }

    public static <T> ResponseData ERROR(T data) {
        return new ResponseData(HttpStatusEnum.ERROR_DEFAULT.getCode(), HttpStatusEnum.ERROR_DEFAULT.getMsg(), data);
    }

    public static <T> ResponseData ERROR(String msg, T data) {
        return new ResponseData(HttpStatusEnum.ERROR_DEFAULT.getCode(), msg, data);
    }

    public static ResponseData FAILED() {
        return new ResponseData(HttpStatusEnum.ERROR_DEFAULT.getCode(), HttpStatusEnum.ERROR_DEFAULT.getMsg(), null);
    }

    public static ResponseData FAILEDMSG(String msg) {
        return new ResponseData(HttpStatusEnum.FAILED_DEFAULT.getCode(), msg, null);
    }

    public static <T> ResponseData FAILED(T data) {
        return new ResponseData(HttpStatusEnum.FAILED_DEFAULT.getCode(), HttpStatusEnum.FAILED_DEFAULT.getMsg(), data);
    }

    public static <T> ResponseData FAILED(String msg, T data) {
        return new ResponseData(HttpStatusEnum.FAILED_DEFAULT.getCode(), msg, data);
    }

    public static <T> ResponseData HttpStatus(HttpStatusEnum httpStatusEnum) {
        return new ResponseData(httpStatusEnum.getCode(), httpStatusEnum.getMsg(), null);
    }

    public static <T> ResponseData HttpStatus(HttpStatusEnum httpStatusEnum, T Data) {
        return new ResponseData(httpStatusEnum.getCode(), httpStatusEnum.getMsg(), Data);
    }

    public static <T> ResponseData HttpStatusMsg(HttpStatusEnum httpStatusEnum, String msg) {
        return new ResponseData(httpStatusEnum.getCode(), msg, null);
    }


}
